@extends('admin.common.web')

@section('title','秒杀商品添加')

@section('content')
<!-- Page Content -->
    <!-- Page Breadcrumb -->
    <div class="page-breadcrumbs">
        <ul class="breadcrumb">
            <li>
                <a href="{{ route('admin.index.index') }}">系统</a>
            </li>
            <li>
                <a href="{{ route('admin.goods.index') }}">商品管理</a>
            </li>
            <li class="active">添加秒杀商品</li>
        </ul>
    </div>
    <!-- /Page Breadcrumb -->
    <!-- Page Body -->
    <div class="page-body">

        <div class="row">
            <div class="col-lg-12 col-sm-12 col-xs-12">
                <div class="widget">
                    <div class="widget-header bordered-bottom bordered-blue">
                        <span class="widget-caption">新增秒杀商品</span>
                    </div>
                    <div class="widget-body">
                        <div id="horizontal-form">
                            @include('admin.common.msg')
                            @include('admin.common.error')
                            <form class="form-horizontal" action="{{ route('admin.goods.addSeckillGoods') }}" method="post" enctype="multipart/form-data">
                                @csrf
                                <div class="form-group">
                                    <label for="goods_name" class="col-sm-2 control-label no-padding-right">商品名称</label>
                                    <div class="col-sm-6">
                                        <input class="form-control" value="{{ $goods['goods_name'] }}" name="goods_name" required type="text">
                                    </div>
                                    <input type="hidden" name="goods_id" value="{{ $goods['id'] }}"/>
                                    @if($errors->has('goods_name'))
                                        <p class="help-block col-sm-4 blue">{{ $errors->first('goods_name') }}</p>
                                    @else
                                        <p class="help-block col-sm-4 red">* 必填</p>
                                    @endif
                                </div>

                                <div class="form-group">
                                    <label for="thumb" class="col-sm-2 control-label no-padding-right">图片</label>
                                    <div class="col-sm-6">
                                        <img src="{{ $goods['thumb'] }}" alt="" width="80" height="80"/>
                                        <input type="hidden" name="thumb" value="{{ $goods['thumb'] }}"/>
                                    </div>
                                    @if($errors->has('thumb'))
                                        <p class="help-block col-sm-4 blue">{{ $errors->first('thumb') }}</p>
                                    @endif
                                </div>

                                <div class="form-group">
                                    <label for="price" class="col-sm-2 control-label no-padding-right">销售价格</label>
                                    <div class="col-sm-6">
                                        <input class="form-control" value="{{ $goods['price'] }}" disabled required type="text">
                                        <input class="form-control" value="{{ $goods['price'] }}" name="price" required type="hidden">
                                    </div>
                                    @if($errors->has('price'))
                                        <p class="help-block col-sm-4 blue">{{ $errors->first('price') }}</p>
                                    @else
                                        <p class="help-block col-sm-4 red">* 必填</p>
                                    @endif
                                </div>

                                <div class="form-group">
                                    <label for="seckill_price" class="col-sm-2 control-label no-padding-right">秒杀价格</label>
                                    <div class="col-sm-6">
                                        <input class="form-control" value="{{ old('seckill_price') }}" name="seckill_price" required type="text">
                                    </div>
                                    @if($errors->has('seckill_price'))
                                        <p class="help-block col-sm-4 blue">{{ $errors->first('seckill_price') }}</p>
                                    @else
                                        <p class="help-block col-sm-4 red">* 必填</p>
                                    @endif
                                </div>

                                <div class="form-group">
                                    <label for="single_num" class="col-sm-2 control-label no-padding-right">单次数量</label>
                                    <div class="col-sm-6">
                                        <input class="form-control" value="{{ old('single_num') ?? 1 }}" name="single_num" required type="text">
                                    </div>
                                    @if($errors->has('single_num'))
                                        <p class="help-block col-sm-4 blue">{{ $errors->first('single_num') }}</p>
                                    @else
                                        <p class="help-block col-sm-4 red">* 必填(单次购买数量)</p>
                                    @endif
                                </div>

                                <div class="form-group">
                                    <label for="start_time" class="col-sm-2 control-label no-padding-right">开始时间</label>
                                    <div class="col-sm-6">
                                        <input class="form-control" autocomplete="off" value="{{ old('start_time') }}" id="start_time" name="start_time" required type="text">
                                    </div>
                                    @if($errors->has('start_time'))
                                        <p class="help-block col-sm-4 blue">{{ $errors->first('start_time') }}</p>
                                    @else
                                        <p class="help-block col-sm-4 red">* 必填</p>
                                    @endif
                                </div>

                                <div class="form-group">
                                    <label for="end_time" class="col-sm-2 control-label no-padding-right">结束时间</label>
                                    <div class="col-sm-6">
                                        <input class="form-control" autocomplete="off" value="{{ old('end_time') }}" id="end_time" name="end_time" required type="text">
                                    </div>
                                    @if($errors->has('end_time'))
                                        <p class="help-block col-sm-4 blue">{{ $errors->first('end_time') }}</p>
                                    @else
                                        <p class="help-block col-sm-4 red">* 必填</p>
                                    @endif
                                </div>

                                <div class="form-group">
                                    <label for="inventory" class="col-sm-2 control-label no-padding-right">秒杀库存</label>
                                    <div class="col-sm-6">
                                        <input class="form-control" name="inventory" value="{{ old('inventory') }}" required type="text">
                                    </div>
                                    @if($errors->has('inventory'))
                                        <p class="help-block col-sm-4 blue">{{ $errors->first('inventory') }}</p>
                                    @else
                                        <p class="help-block col-sm-4 red">* 不能大于 {{ $goods['inventory'] }}</p>
                                    @endif
                                </div>

                                {{--<div class="form-group">
                                    <label for="sale_num" class="col-sm-2 control-label no-padding-right">展示销量</label>
                                    <div class="col-sm-6">
                                        <input class="form-control" value="{{ old('sale_num') ?? 1 }}" name="sale_num" required type="text">
                                    </div>
                                    @if($errors->has('sale_num'))
                                        <p class="help-block col-sm-4 blue">{{ $errors->first('sale_num') }}</p>
                                    @else
                                        <p class="help-block col-sm-4 red">* 必填</p>
                                    @endif
                                </div>--}}

                                <div class="form-group">
                                    <label for="sort" class="col-sm-2 control-label no-padding-right">排序</label>
                                    <div class="col-sm-6">
                                        <input class="form-control" value="{{ old('sort') ?? 0 }}" name="sort" required type="text">
                                    </div>
                                    @if($errors->has('sort'))
                                        <p class="help-block col-sm-4 blue">{{ $errors->first('sort') }}</p>
                                    @else
                                        <p class="help-block col-sm-4 red">* 必填</p>
                                    @endif
                                </div>

                                <div class="form-group">
                                    <label for="username" class="col-sm-2 control-label no-padding-right">秒杀状态</label>
                                    <div class="col-sm-6">
                                        <div class="radio">
                                            <label>
                                                <input name="kill_status" type="radio" value="1" checked class="colored-blue">
                                                <span class="text">开启</span>
                                            </label>

                                            <label>
                                                <input name="kill_status" type="radio" value="0" class="colored-danger">
                                                <span class="text">关闭</span>
                                            </label>
                                        </div>
                                    </div>
                                    @if($errors->has('kill_status'))
                                        <p class="help-block col-sm-4 blue">{{ $errors->first('kill_status') }}</p>
                                    @endif
                                </div>


                                <div class="form-group">
                                    <div class="col-sm-offset-2 col-sm-10">
                                        <button type="submit" class="btn btn-info">保存信息</button>
                                        <a href="JavaScript:window.history.go(-1);" class="btn btn-default">返回</a>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <!-- /Page Body -->
@endsection

@section('script')
    <script type="text/javascript" src="{{  asset('plugins/laydate/laydate.js') }}"></script>

    <script>
        laydate.render({
            elem: '#start_time', //指定元素
            type: 'datetime'
        });

        laydate.render({
            elem: '#end_time',
            type: 'datetime'
        });
    </script>
@endsection
